package com.kdl.webconfig.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kdl.webconfig.vo.BasePageVO;
import com.kdl.webconfig.entity.CustomInfo;
import com.kdl.webconfig.mapper.CustomInfoMapper;
import com.kdl.webconfig.service.ICustomInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 客户信息表 服务实现类
 * </p>
 *
 * @author wcj
 * @since 2022-09-05
 */
@Service
public class CustomInfoServiceImpl extends ServiceImpl<CustomInfoMapper, CustomInfo> implements ICustomInfoService {

    @Resource
    private CustomInfoMapper customInfoMapper;
    @Override
    public Page<CustomInfo> queryPage(BasePageVO basePageVO) {
        Page<CustomInfo> newsPage = new Page<>(basePageVO.getPageNo(), basePageVO.getPageSize());
        QueryWrapper<CustomInfo> newsQueryWrapper = new QueryWrapper<>();
        newsPage = customInfoMapper.selectPage(newsPage, newsQueryWrapper);
        return newsPage;
    }

    @Override
    public Integer deleteById(Integer id) {
        CustomInfo customInfo = new CustomInfo();
        customInfo.setId(id);
        customInfo.setDeleteFlag(1);
        return customInfoMapper.updateById(customInfo);
    }

    @Override
    public List<CustomInfo> selectCustomInfo() {
        QueryWrapper<CustomInfo> customInfoQueryWrapper = new QueryWrapper<>();
        customInfoQueryWrapper.lambda().eq(CustomInfo::getDeleteFlag,0);
        return customInfoMapper.selectList(customInfoQueryWrapper);
    }
}
